


# A = {1:3, 2:5,4:6}
# B = {1:5, 3:7,4:6}
# for key,value in B.items():
#     if key in A:
#         A[key] += value
#     else:
#         A[key] = value
# print(dict(sorted(A.items(), key=lambda d:d[1],reverse=True)))

dic1={1:3,2:5,4:6,}
dic2={1:5,3:7,4:6}
dic3={}
for i in dic1:
    if i in dic2.keys():
        dic3[i]=dic1[i]+dic2[i]
        dic2.pop(i)
    else:
        dic3[i]=dic1[i]
# for j in dic2:
#     dic3[j]=dic2[j]
dic3.update(dic2)
print(dic3)
def func(k):
    return dic3[k]
print(max(dic3,key=func))
print(dict(sorted(dic3.items(), key=lambda d:d[1],reverse=True)))
for i in sorted(dic3,key=lambda k:dic3[k]):
    print(dic3.get(i))

#增加元素
dic={'小明':13299887777,'特朗普':814666888,'普京':522888666,'吴京':13999887777}
user=input('请输入你要查找的用户\n')
if user.strip() in dic:
    print('已存在该用户')
else:
    phonenumber=int(input('请输入电话号码\n'))
    dic[user]=phonenumber
print(dic)

#更新
dic={'小明':13299887777,'特朗普':814666888,'普京':522888666,'吴京':13999887777}
user=input('请输入你要查找的用户\n')
if user.strip() in dic:
    phonenumber=int(input('请输入电话号码\n'))
    dic[user]=phonenumber
else:
    print('数据不存在')
print(dic)













